<%@ taglib prefix="s" uri="/struts-tags"%>
<link media="screen" type="text/css" href="../resources/css/style.css" rel="stylesheet">
<html>
<head>
<title>Authors List</title>
</head>
<body>
 
<p>Authors List</p>

<s:if test="authors.size > 0">
	
	<table align="center" class="listing">
	    <tr><td class="hed" colspan="6">List of authors</td></tr>
	    <tr>
	        <th>First Name</th>
	        <th>Last Name</th>
	        <th>Blog</th>
	        <th>Books</th>
	        <th>&nbsp;</th>
	    </tr>
	   <s:iterator var="author"  value="authors">
	    <tr <s:if test="author_index%2 = 0"> class="bg"</s:if>>
	        <td><s:property value="#author.firstName" /></td>
	        <td><s:property value="#author.lastName" /></td>
	        <td><s:property value="#author.blog" /></td>
	        <td>
	      
		       <s:if test="#author.books.size > 0">  
		       	  <ul>
		          <s:iterator var="book"  value="#author.books">
			    	<li> <s:property value="#book.title" /><br>
			      </s:iterator>
			      </ul>
		       </s:if> 
	        </td>
	        <td><s:url id="editURL" action="updateAuthor" >
					<s:param name="codeAuthors" value="%{#author.id}"></s:param>
				</s:url>
				<s:a href="%{editURL}">Edit</s:a>
			</td>
			 <td><s:url id="deleteURL" action="deleteAuthor" >
					<s:param name="codeAuthors" value="%{#author.id}"></s:param>
				</s:url>
				<s:a href="%{deleteURL}">Delete</s:a>
			</td>
	    </tr>
		</s:iterator>
		<tr>
			<td colspan="6" align="center"> size : <s:property value="authors.size"/></td>
		</tr>
	</table>
		
</s:if>
 <div><s:url id="addUser" value="addAuthorForm">
</s:url><s:a href="%{addUser}">Add</s:a></div>
</body>
</html>